package common.utils;

import lombok.var;
import redis.clients.jedis.Jedis;

public class RedisUtil {

    private static Jedis jedis;

    static {
        jedis = new Jedis("localhost");
        // jedis.auth("123456");
        jedis.select(0);
        System.out.println("Redis连接成功,运行状态: " + jedis.ping());
    }

    public static void set(String key, Object value) {
        jedis.set(key, JacksonUtil.serialize(value));
    }

    public static Object get(String key) {
        var value = jedis.get(key);
        return JacksonUtil.deserialize(Object.class, value);
    }

}
